import { useState, useDebugValue } from "react";

// hooks的名字必须由use开头
const useCounter = (n) => {
  useDebugValue("counter");

  const [count, setCount] = useState(n);
  const add = () => {
    setCount((v) => v + 1);
  };
  const minus = () => {
    setCount((v) => v - 1);
  };

  return [count, add, minus];
};

export default useCounter;
